{extend name="index/index" /}
{block name="main"}
{js href="/static/index/js/jquery.min.js"}
<!-- Start right content -->

<!---->
<div class="content-page">

    <div class="content">

        <div class="page-heading">
            <h1><i class='fa fa-table'></i>评论管理</h1>
            <h3>文章评论列表</h3></div>

        <div class="row">

            <div class="col-md-12">
                <div class="widget">
                    <div class="widget-header transparent">
                        <h2><strong>Sortable</strong> Table</h2>

                    </div>
                    <div class="widget-content">
                        <div class="table-responsive">
                            <table data-sortable class="table">
                                <thead>
                                <tr>
                                    <th>文章名</th>
                                    <th>评论次数</th>
                                    <th class="col-md-2">操作</th>
                                    {volist name='artlist' id='val' }
                                    <tr>
                                        <td>{$val.artname}</td>
                                        <td>{$val.num}</td>
                                        <td>
                                            <a href="{:url('admin/comment/artdetail',['id'=>$val['art_id']])}" class="btn btn-info">评论详情</a>
                                        </td>
                                    </tr>
                                    {/volist}

                                </tr>
                                </thead>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>


<!-- 修改数据模态框 -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="width: 500px;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    修改状态
                </h4>
            </div>
            <form class="form-horizontal" method="post" style="margin-top:30px;">
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">帖子名</label>
                                    <div class="col-sm-5">
                                        <input type="input" class="form-control" id="postname" name="postname" value="">
                                    </div>
                                </div>
                                
                                <div class="form-group aa">
                                    <label class="col-sm-2 control-label">帖子状态</label>
                                    <div class="col-sm-5">
                                        <input type="input" class="form-control" id="poststatus" name="status" value="">
                                        <input type="hidden" id="idid" name="idid" value="">
                                        <p>'零' 代表精华 '一' 代表普通</p>
                                    </div>
                                </div>
                            </form>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                </button>
                <button type="button" class="btn btn-primary update">
                    提交更改
                </button>
            </div>
        </div>
    </div>
</div>


<!-- 修改状态模态框结束 -->


        <!-- Footer Start -->
        <footer>
            Huban Creative &copy; 2014
            <div class="footer-links pull-right">
                <a href="#">About</a><a href="#">Support</a><a href="#">Terms of Service</a><a href="#">Legal</a><a
                    href="#">Help</a><a href="#">Contact Us</a>
            </div>
        </footer>
        <!-- Footer End -->
    </div>
    <!-- ============================================================== -->
    <!-- End content here -->
    <!-- ============================================================== -->

</div>
<!-- End right content -->
<!-- 修改状态js -->
<script type="text/javascript">
    
    $('.staupdate').click(function (){
        var postid = $(this).attr('post-id');
       
        var info = 'postid'+'='+postid;
        
        $.ajax({
            type: 'post',
            url: '/admin/post/edit',
            data: info, 
            dataType : 'json',
            success : function (data){
                // alert(data.posthot);
                // die;
                $('#postname').val(data.postname);
                $('#poststatus').val(data.posthot);
                $('#idid').val(data.post_id);
                

            },
            error : function () {
                 alert('执行失败');
                
            }
        });

    });

</script>

<script type="text/javascript">
    
    $('.update').click(function (){

        var info = $('.form-horizontal input').serialize();
        // var info = 'postname'+'='+$('#postname').val()+'&'+$('.aa input').serialize()
        // alert(info);
        $.ajax({
            type: 'post',
            url: '/admin/post/update',
            data: info,
            dataType : 'json',
            success : function (data){
                toastr.success('修改成功');
                setTimeout(function (){
                    window.location.reload();
                },1000);
            },
            error : function () {
                toastr.error('执行失败');
                 
                
            }
        });

    });

</script>

<!-- 修改状态js -->





<script type="text/javascript">


    $(function () {
            // 触发删除用户
            $('.delArt').click(function () {
                var dataid = $(this).attr('data-id');
                    // alert(dataid);

                if (confirm('您确定要 [ 删 除 ] 该用户吗?')) {
                    var obj = $(this).parents('tr');

                    // alert(obj);
                    delAjax(dataid, obj); // 执行AJAX删除

                }
        });
    })
   




    toastr.options = {
    closeButton: true,// 是否显示关闭按钮
    progressBar: true,// 实现显示计时条
    timeOut: "1000",// 自动关闭时间
    positionClass: "toast-bottom-left"// 提示位置
    // positionClass: "toast-top-full-width"// 提示位置
    // toast-top-full-width 顶端，宽度铺满整个屏幕
    // toast-top-right  顶端右边
    };

    function delAjax(id,obj) {

    

        var info = 'postid'+'='+id;
        // alert(info);
        
        $.ajax({
            type: 'post',
            url: '/admin/post/delete',
            data: info,
            dataType : 'json',
            success : function (data){

                 if (data.status) {
                    toastr.success('删除成功');
                    obj.remove();
                } else {
                    toastr.error('删除失败');
                }


            },
            error : function () {
                 alert('执行失败');
                
            }
        });
    }

</script>


{/block}